package OneDay;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

//T3956
public class Main {
    public static void main(String[] args) throws IOException {
        final int N = 100005;
        int[] s = new int[N];

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());

        String[] line = in.readLine().split(" ");

        for (int i = 1; i <= n; i++) {
            s[i] = Integer.parseInt(line[i - 1]);
            s[i] += s[i - 1];
        }

        if(n < 3 || s[n] % 3 != 0){
            System.out.println(0);
            return;
        }

        long ans = 0,tmp = 0;
        for (int i = 1; i < n; i++) {
            if(s[i] == s[n] / 3){
                tmp++;
            }
            if(s[i] == s[n] / 3 * 2){
                ans += tmp;
            }
        }

        System.out.println(ans);
    }
}
